/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "hks_import_rsa_test.h"
#include "hks_test_adapt_for_de.h"

#include <gtest/gtest.h>
#include <hks_log.h>
#ifdef L2_STANDARD
#include "file_ex.h"
#endif

using namespace testing::ext;
namespace Unittest::ImportRsaTest {
class HksImportRsaTest : public testing::Test {
public:
    static void SetUpTestCase(void);

    static void TearDownTestCase(void);

    void SetUp();

    void TearDown();
};

void HksImportRsaTest::SetUpTestCase(void)
{
}

void HksImportRsaTest::TearDownTestCase(void)
{
}

void HksImportRsaTest::SetUp()
{
    EXPECT_EQ(HksInitialize(), 0);
}

void HksImportRsaTest::TearDown()
{
}

#ifdef HKS_UNTRUSTED_RUNNING_ENV
static const uint8_t g_eData[] = { 0x01, 0x00, 0x01 };

static const uint8_t g_nData512[] = {
    0xb6, 0xd8, 0x9b, 0x33, 0x78, 0xa2, 0x63, 0x21, 0x84, 0x47, 0xa1, 0x72, 0x3d, 0x73, 0x10, 0xbd,
    0xe9, 0x5d, 0x78, 0x44, 0x3d, 0x80, 0x18, 0x12, 0x60, 0xed, 0x29, 0x3e, 0xc7, 0x23, 0x0d, 0x3f,
    0x02, 0x59, 0x28, 0xe2, 0x8f, 0x83, 0xdf, 0x37, 0x4b, 0x77, 0xce, 0x5f, 0xb6, 0xcd, 0x61, 0x72,
    0xee, 0x01, 0xe2, 0x37, 0x4d, 0xfd, 0x4f, 0x39, 0xcf, 0xbd, 0xff, 0x84, 0x57, 0x44, 0xa5, 0x03,
};

static const uint8_t g_dData512[] = {
    0x35, 0x63, 0x89, 0xed, 0xbd, 0x8b, 0xac, 0xe6, 0x5c, 0x79, 0x8d, 0xea, 0x8d, 0x86, 0xcb, 0x9c,
    0xa8, 0x47, 0x62, 0x96, 0x8a, 0x5e, 0x9c, 0xa8, 0xc1, 0x24, 0x7e, 0xa6, 0x95, 0xfe, 0xe6, 0x1e,
    0xc0, 0xf3, 0x29, 0x76, 0xbb, 0x4d, 0xe4, 0xbc, 0x78, 0x64, 0xe1, 0x79, 0xcd, 0x8a, 0x45, 0xac,
    0x5c, 0x88, 0xea, 0xb4, 0x10, 0xd8, 0x90, 0x65, 0x7b, 0x94, 0xe8, 0x87, 0x30, 0x2a, 0x04, 0x01,
};

static const uint8_t g_nData768[] = {
    0xc7, 0x06, 0x9c, 0x4b, 0x70, 0x57, 0x9a, 0xb9, 0xd0, 0x3a, 0x4b, 0x0b, 0xb8, 0x4b, 0x81, 0x54,
    0xe7, 0xba, 0xfa, 0xda, 0xf5, 0x04, 0xf0, 0x28, 0x42, 0x6a, 0xb5, 0xb9, 0xf5, 0x1c, 0x5c, 0x2d,
    0xc1, 0x11, 0xe6, 0xe6, 0xe6, 0xfc, 0xeb, 0x33, 0xa0, 0x45, 0xa9, 0x3b, 0xbf, 0x8f, 0x9d, 0x6e,
    0xf5, 0x26, 0xe7, 0xa1, 0xf5, 0x8d, 0x48, 0x48, 0x7f, 0x2a, 0xf8, 0x05, 0x43, 0xd5, 0xea, 0x56,
    0xf4, 0xcf, 0x95, 0xf7, 0x7e, 0x34, 0x0f, 0xee, 0x46, 0x34, 0x05, 0x42, 0x01, 0xce, 0xce, 0xa0,
    0xa4, 0x70, 0x61, 0xb1, 0x99, 0x0d, 0xd8, 0x3c, 0xbf, 0xf9, 0xb2, 0x2a, 0x32, 0x51, 0x3d, 0xc5,
};

static const uint8_t g_dData768[] = {
    0x5b, 0x7c, 0xf0, 0x6f, 0xc5, 0x2e, 0xa0, 0x13, 0x76, 0x62, 0xb5, 0x88, 0xa7, 0xa9, 0x1d, 0xc4,
    0x97, 0xd9, 0x5d, 0xe3, 0x34, 0xea, 0x96, 0x33, 0x0b, 0x84, 0xde, 0x10, 0xa3, 0x59, 0xec, 0x0d,
    0xa4, 0x48, 0xc4, 0x69, 0xb4, 0x18, 0xe3, 0x4d, 0x92, 0x09, 0x33, 0xa8, 0x21, 0x80, 0xb5, 0x0f,
    0x32, 0xd7, 0x04, 0xf3, 0x4e, 0x77, 0xba, 0x9b, 0xc5, 0x20, 0x2c, 0x1e, 0xf7, 0xb3, 0x87, 0x08,
    0x03, 0x1f, 0x12, 0x63, 0x4a, 0xbe, 0x5f, 0x71, 0x4d, 0xf5, 0x5d, 0x3e, 0x4a, 0xaf, 0x84, 0x17,
    0x50, 0x9a, 0x5e, 0x04, 0x9e, 0x1f, 0x5a, 0xbd, 0x63, 0xe7, 0x76, 0x0b, 0x00, 0x22, 0x77, 0xa9,
};

static const uint8_t g_nData1024[] = {
    0xc7, 0x5e, 0x46, 0xc3, 0x5b, 0x4f, 0x9f, 0x2f, 0x5a, 0xcf, 0x31, 0x65, 0xcc, 0x71, 0x6e, 0x47,
    0x60, 0x17, 0x1d, 0x86, 0xb9, 0x8f, 0xe5, 0x4b, 0x85, 0x7a, 0x67, 0xfe, 0xa2, 0x03, 0x05, 0x55,
    0x16, 0xab, 0x51, 0x20, 0x65, 0xc6, 0x83, 0x24, 0x82, 0x58, 0xda, 0x7a, 0xf9, 0x3f, 0x56, 0xa7,
    0xcb, 0x02, 0x8c, 0xfc, 0x4c, 0xf0, 0x17, 0xdf, 0x8f, 0x80, 0x6a, 0xf3, 0x35, 0xc7, 0x52, 0xa8,
    0x4c, 0xef, 0xba, 0x99, 0xc5, 0x2f, 0xc2, 0x9f, 0x78, 0x1d, 0xa5, 0x1a, 0xc0, 0x28, 0x66, 0x42,
    0xa9, 0x65, 0x63, 0xe8, 0xc1, 0x9a, 0xe4, 0xb6, 0xa6, 0x89, 0xac, 0x59, 0xd0, 0xcf, 0x17, 0xc9,
    0x93, 0x6e, 0x57, 0xeb, 0xa1, 0xc2, 0xe1, 0x23, 0x9a, 0x74, 0xbd, 0x60, 0xd1, 0x98, 0x9a, 0x41,
    0xa5, 0x9d, 0xff, 0x71, 0x01, 0x94, 0x97, 0x65, 0x7e, 0xd9, 0xab, 0xa8, 0x64, 0xeb, 0x41, 0xe9,
};

static const uint8_t g_dData1024[] = {
    0xc5, 0x48, 0x0a, 0x37, 0xf8, 0x5c, 0x52, 0xc6, 0x16, 0x53, 0x1e, 0xab, 0x80, 0x61, 0xe2, 0x61,
    0x68, 0xb9, 0x96, 0xf3, 0x21, 0x1e, 0x3e, 0x24, 0xbc, 0x41, 0x83, 0x34, 0xda, 0x76, 0xa8, 0xc9,
    0x29, 0x34, 0x7f, 0x83, 0xd2, 0x92, 0x5c, 0x65, 0x3d, 0x42, 0xd5, 0x77, 0x88, 0xba, 0xdf, 0x72,
    0x0c, 0x96, 0x4a, 0x92, 0xc3, 0x43, 0x76, 0x2c, 0x38, 0x21, 0x38, 0x33, 0xd0, 0xcc, 0x9b, 0x81,
    0xc5, 0x87, 0xd7, 0x69, 0x8f, 0x1a, 0xb0, 0x59, 0xef, 0xb8, 0x57, 0x0f, 0x7f, 0xcd, 0x72, 0xfb,
    0xf0, 0xe0, 0x9a, 0xa9, 0x92, 0x08, 0x58, 0x9a, 0xf1, 0xca, 0xe3, 0x6e, 0x87, 0x88, 0xfd, 0xb4,
    0x99, 0xec, 0x37, 0xf0, 0x0b, 0x48, 0x9b, 0xf1, 0x85, 0x78, 0x20, 0x69, 0xb5, 0xe6, 0xdd, 0xe6,
    0x9c, 0x71, 0x1c, 0x17, 0xc6, 0x3d, 0x18, 0x9b, 0xfa, 0x08, 0x7d, 0xe0, 0xd9, 0x05, 0x4c, 0x3d,
};

static const uint8_t g_nData3072[] = {
    0xda, 0xa5, 0x05, 0x33, 0x0c, 0x08, 0x77, 0x97, 0xf3, 0x9f, 0x11, 0xab, 0x2c, 0xb3, 0xc0, 0xd7,
    0xd2, 0x4e, 0x84, 0x62, 0xd8, 0x40, 0x27, 0x4f, 0xb3, 0x3e, 0xa4, 0x61, 0x75, 0xa9, 0x20, 0x1f,
    0xc4, 0xe2, 0x79, 0xe9, 0xf5, 0xba, 0xcc, 0x49, 0x30, 0x03, 0xf3, 0xd4, 0x1b, 0x81, 0xa2, 0x2e,
    0xa3, 0x3a, 0x1e, 0xb9, 0x5e, 0xdc, 0xcd, 0x1b, 0xad, 0x64, 0xfb, 0xb6, 0x78, 0x2f, 0xf6, 0x14,
    0x8d, 0x5f, 0x23, 0xca, 0xbd, 0x81, 0xa5, 0x66, 0xfa, 0x26, 0xc8, 0xe1, 0xa4, 0x16, 0x23, 0x78,
    0x49, 0x00, 0xc1, 0xe5, 0xa8, 0xa0, 0x2f, 0xf7, 0xac, 0xcc, 0x82, 0x6f, 0xa1, 0x89, 0xd9, 0x2f,
    0x44, 0x9f, 0x3d, 0x42, 0x81, 0xae, 0x0e, 0xcb, 0x83, 0xaf, 0x4c, 0x7a, 0x82, 0x2c, 0x8e, 0xc6,
    0x88, 0x18, 0x09, 0xaf, 0x15, 0xd0, 0xe9, 0xfa, 0xb5, 0xc2, 0x67, 0xac, 0x49, 0x96, 0x5b, 0x42,
    0x99, 0x20, 0x95, 0xb2, 0xf7, 0x26, 0x31, 0x83, 0x8c, 0x22, 0x09, 0xea, 0x63, 0xe4, 0x12, 0x8a,
    0x42, 0x3a, 0x71, 0xc9, 0xa0, 0xb5, 0xb2, 0x45, 0xe6, 0x0d, 0xda, 0x94, 0xd3, 0x70, 0xcc, 0x7f,
    0x31, 0xd4, 0x3f, 0xe6, 0xed, 0xf5, 0x43, 0x73, 0xf6, 0x06, 0x7f, 0x13, 0x65, 0x43, 0xd4, 0x35,
    0xf2, 0xfc, 0x75, 0x3a, 0xfe, 0x8e, 0x14, 0x5e, 0xa1, 0xed, 0xd1, 0xd2, 0x96, 0x88, 0xbb, 0xe4,
    0x23, 0x52, 0x51, 0x02, 0x81, 0xa6, 0xf9, 0xad, 0x81, 0xf4, 0xf0, 0xc0, 0x40, 0xbf, 0x4b, 0x97,
    0x6f, 0x87, 0x8e, 0xc7, 0xbd, 0xf2, 0x73, 0x2f, 0xe5, 0x3c, 0x62, 0xba, 0x5f, 0xac, 0xb9, 0x83,
    0x0c, 0x61, 0x74, 0xed, 0x0b, 0xbe, 0xff, 0x2a, 0xcf, 0x6d, 0xff, 0xc4, 0x16, 0x3b, 0xb4, 0x2b,
    0x57, 0x62, 0x84, 0xa6, 0x6f, 0xfb, 0x32, 0x72, 0xd7, 0x61, 0xc2, 0x1d, 0x54, 0x3b, 0xa2, 0xd2,
    0x47, 0xe0, 0x96, 0x72, 0xad, 0x28, 0x75, 0xfe, 0x47, 0xdf, 0xf6, 0xcb, 0xaf, 0x56, 0x9d, 0x2b,
    0x1d, 0x62, 0x26, 0xd8, 0xe5, 0xa6, 0x2a, 0xc9, 0x0a, 0x85, 0x71, 0x63, 0x2e, 0x16, 0x17, 0xf4,
    0x2f, 0x17, 0x01, 0x8a, 0x3d, 0x2f, 0xd2, 0xb2, 0x80, 0xa1, 0x04, 0x30, 0x38, 0x0c, 0xeb, 0x06,
    0x2e, 0xc4, 0x4f, 0x80, 0xfb, 0x6b, 0xf7, 0x3c, 0x53, 0x41, 0x5e, 0xdc, 0xc1, 0xfd, 0x1a, 0xda,
    0x0c, 0x58, 0xa5, 0xb0, 0x99, 0xb2, 0xcd, 0x8f, 0x52, 0x81, 0xd1, 0x82, 0xb2, 0x3b, 0x07, 0xaf,
    0xd0, 0xd4, 0xd7, 0x92, 0xd3, 0x51, 0x87, 0x13, 0x4c, 0xf7, 0x87, 0xb9, 0x74, 0x42, 0xde, 0x8c,
    0x65, 0xe2, 0x68, 0xce, 0x62, 0x5d, 0x02, 0xed, 0xa6, 0xff, 0xf2, 0x87, 0x2a, 0x00, 0xae, 0xbe,
    0xe0, 0xda, 0xe5, 0xfe, 0xb4, 0xb8, 0x0a, 0xfb, 0xfe, 0x89, 0x43, 0xde, 0xd2, 0xb6, 0x4e, 0x81,
};

static const uint8_t g_dData3072[] = {
    0xd7, 0xd6, 0xbf, 0xe3, 0x3c, 0xa5, 0xbf, 0x29, 0xc9, 0xdd, 0xe5, 0xdb, 0x4d, 0x2d, 0xc5, 0xd9,
    0x48, 0x4b, 0x2a, 0x75, 0x49, 0x75, 0x4b, 0x59, 0x6a, 0x61, 0x14, 0x75, 0x01, 0x6a, 0x0b, 0xc4,
    0x50, 0xe0, 0x21, 0xe9, 0xcc, 0x22, 0xb3, 0x38, 0x2c, 0xa6, 0x3a, 0x35, 0xd1, 0x51, 0x8f, 0x80,
    0xea, 0xb1, 0x9d, 0x52, 0xf1, 0x4a, 0x97, 0x50, 0x13, 0x43, 0xf5, 0x18, 0x94, 0x5d, 0x04, 0x58,
    0x15, 0x97, 0x2e, 0x06, 0x1e, 0x3d, 0xb5, 0xc2, 0x8a, 0x7f, 0x6f, 0x1f, 0x10, 0x94, 0xaa, 0x3f,
    0x3c, 0x11, 0xfb, 0x57, 0x73, 0xb7, 0x6e, 0xa2, 0xd9, 0x7a, 0xa9, 0xe8, 0xf9, 0x56, 0xd3, 0x87,
    0xcd, 0xfe, 0x44, 0xc3, 0x3a, 0xb1, 0x50, 0xf9, 0xa6, 0xed, 0x8e, 0x5a, 0x01, 0xd7, 0x6a, 0xba,
    0xa1, 0xee, 0xd8, 0xe0, 0x76, 0x70, 0xde, 0x0a, 0x19, 0x13, 0xe8, 0xb4, 0x33, 0x90, 0xb2, 0x56,
    0x74, 0x43, 0xae, 0x84, 0x15, 0x67, 0x26, 0xc9, 0xed, 0xb4, 0x4c, 0x85, 0x8e, 0x46, 0xbf, 0xe6,
    0xac, 0xaa, 0x75, 0x59, 0xcd, 0xc4, 0x90, 0x50, 0x60, 0x62, 0x9c, 0xbc, 0xfe, 0x5e, 0x04, 0x02,
    0x2c, 0x76, 0x92, 0xfe, 0xad, 0x39, 0xc9, 0x74, 0xd8, 0x12, 0x61, 0xb0, 0x0b, 0xef, 0x81, 0xb6,
    0x20, 0x41, 0x08, 0x99, 0x4c, 0x61, 0x85, 0xca, 0x45, 0xa0, 0x37, 0xd9, 0xe3, 0xb0, 0xe7, 0x88,
    0xe3, 0x7c, 0xd0, 0x70, 0xc2, 0x38, 0x22, 0x50, 0xd8, 0xa8, 0xe8, 0xba, 0x76, 0x6e, 0x4b, 0x9d,
    0x2b, 0x5c, 0x84, 0xf7, 0x0b, 0xce, 0xc9, 0x63, 0x5c, 0x6e, 0x27, 0xa3, 0xac, 0xad, 0x42, 0xfb,
    0xa6, 0x6c, 0x48, 0xca, 0x10, 0xa2, 0x30, 0x29, 0xc3, 0x00, 0x07, 0x2c, 0xd8, 0x3f, 0xd1, 0x39,
    0xee, 0x58, 0x9a, 0x8b, 0x54, 0x8b, 0xf0, 0xc4, 0x3a, 0xeb, 0x84, 0xda, 0x14, 0x63, 0x06, 0xe0,
    0x03, 0xcb, 0x83, 0x75, 0x61, 0xa5, 0x54, 0x24, 0xc3, 0xb6, 0xd8, 0xa8, 0xbc, 0x26, 0x50, 0x74,
    0x45, 0x9d, 0x7a, 0xea, 0xe2, 0x37, 0xf0, 0xfb, 0x5a, 0xd1, 0xff, 0x3b, 0x97, 0x43, 0xad, 0xf5,
    0x19, 0xbf, 0x7a, 0x6f, 0xb7, 0x68, 0x50, 0xbb, 0x84, 0xaa, 0x6e, 0xc8, 0xf4, 0xd2, 0x4e, 0xd0,
    0x5d, 0xd2, 0x19, 0x22, 0xaf, 0xf1, 0xd2, 0x39, 0x93, 0x7d, 0xfa, 0x00, 0x1b, 0x61, 0x02, 0x82,
    0xcf, 0x13, 0xf1, 0xdf, 0x09, 0x9d, 0x73, 0xeb, 0x3a, 0x3a, 0x8b, 0x01, 0x02, 0xff, 0xf3, 0x1a,
    0xa3, 0xb3, 0x3a, 0xe8, 0xac, 0xd1, 0x72, 0xe4, 0xac, 0x31, 0x25, 0x17, 0xe1, 0xdb, 0x7d, 0x9b,
    0x04, 0x2d, 0x58, 0xbf, 0x27, 0xa2, 0x49, 0x4e, 0x3d, 0x84, 0x0b, 0xd6, 0xf0, 0x1d, 0xc9, 0x80,
    0xfb, 0xf5, 0x80, 0xa5, 0x06, 0x75, 0x97, 0xf2, 0x09, 0x41, 0x4c, 0xe4, 0x10, 0x2b, 0xfc, 0x61,
};

static const uint8_t g_pubData512[] = {
    0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
    0x00, 0x03, 0x4b, 0x00, 0x30, 0x48, 0x02, 0x41, 0x00, 0xb6, 0xd8, 0x9b, 0x33, 0x78, 0xa2, 0x63,
    0x21, 0x84, 0x47, 0xa1, 0x72, 0x3d, 0x73, 0x10, 0xbd, 0xe9, 0x5d, 0x78, 0x44, 0x3d, 0x80, 0x18,
    0x12, 0x60, 0xed, 0x29, 0x3e, 0xc7, 0x23, 0x0d, 0x3f, 0x02, 0x59, 0x28, 0xe2, 0x8f, 0x83, 0xdf,
    0x37, 0x4b, 0x77, 0xce, 0x5f, 0xb6, 0xcd, 0x61, 0x72, 0xee, 0x01, 0xe2, 0x37, 0x4d, 0xfd, 0x4f,
    0x39, 0xcf, 0xbd, 0xff, 0x84, 0x57, 0x44, 0xa5, 0x03, 0x02, 0x03, 0x01, 0x00, 0x01,
};

static const uint8_t g_pubData768[] = {
    0x30, 0x7c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
    0x00, 0x03, 0x6b, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xc7, 0x06, 0x9c, 0x4b, 0x70, 0x57, 0x9a,
    0xb9, 0xd0, 0x3a, 0x4b, 0x0b, 0xb8, 0x4b, 0x81, 0x54, 0xe7, 0xba, 0xfa, 0xda, 0xf5, 0x04, 0xf0,
    0x28, 0x42, 0x6a, 0xb5, 0xb9, 0xf5, 0x1c, 0x5c, 0x2d, 0xc1, 0x11, 0xe6, 0xe6, 0xe6, 0xfc, 0xeb,
    0x33, 0xa0, 0x45, 0xa9, 0x3b, 0xbf, 0x8f, 0x9d, 0x6e, 0xf5, 0x26, 0xe7, 0xa1, 0xf5, 0x8d, 0x48,
    0x48, 0x7f, 0x2a, 0xf8, 0x05, 0x43, 0xd5, 0xea, 0x56, 0xf4, 0xcf, 0x95, 0xf7, 0x7e, 0x34, 0x0f,
    0xee, 0x46, 0x34, 0x05, 0x42, 0x01, 0xce, 0xce, 0xa0, 0xa4, 0x70, 0x61, 0xb1, 0x99, 0x0d, 0xd8,
    0x3c, 0xbf, 0xf9, 0xb2, 0x2a, 0x32, 0x51, 0x3d, 0xc5, 0x02, 0x03, 0x01, 0x00, 0x01,
};

static const uint8_t g_pubData1024[] = {
    0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01,
    0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xc7, 0x5e, 0x46,
    0xc3, 0x5b, 0x4f, 0x9f, 0x2f, 0x5a, 0xcf, 0x31, 0x65, 0xcc, 0x71, 0x6e, 0x47, 0x60, 0x17, 0x1d,
    0x86, 0xb9, 0x8f, 0xe5, 0x4b, 0x85, 0x7a, 0x67, 0xfe, 0xa2, 0x03, 0x05, 0x55, 0x16, 0xab, 0x51,
    0x20, 0x65, 0xc6, 0x83, 0x24, 0x82, 0x58, 0xda, 0x7a, 0xf9, 0x3f, 0x56, 0xa7, 0xcb, 0x02, 0x8c,
    0xfc, 0x4c, 0xf0, 0x17, 0xdf, 0x8f, 0x80, 0x6a, 0xf3, 0x35, 0xc7, 0x52, 0xa8, 0x4c, 0xef, 0xba,
    0x99, 0xc5, 0x2f, 0xc2, 0x9f, 0x78, 0x1d, 0xa5, 0x1a, 0xc0, 0x28, 0x66, 0x42, 0xa9, 0x65, 0x63,
    0xe8, 0xc1, 0x9a, 0xe4, 0xb6, 0xa6, 0x89, 0xac, 0x59, 0xd0, 0xcf, 0x17, 0xc9, 0x93, 0x6e, 0x57,
    0xeb, 0xa1, 0xc2, 0xe1, 0x23, 0x9a, 0x74, 0xbd, 0x60, 0xd1, 0x98, 0x9a, 0x41, 0xa5, 0x9d, 0xff,
    0x71, 0x01, 0x94, 0x97, 0x65, 0x7e, 0xd9, 0xab, 0xa8, 0x64, 0xeb, 0x41, 0xe9, 0x02, 0x03, 0x01,
    0x00, 0x01,
};

static const uint8_t g_pubData2048[] = {
    0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
    0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01,
    0x00, 0xc5, 0x35, 0x62, 0x48, 0xc4, 0x92, 0x87, 0x73, 0x0d, 0x42, 0x96, 0xfc, 0x7b, 0x11, 0x05,
    0x06, 0x0f, 0x8d, 0x66, 0xc1, 0x0e, 0xad, 0x37, 0x44, 0x92, 0x95, 0x2f, 0x6a, 0x55, 0xba, 0xec,
    0x1d, 0x54, 0x62, 0x0a, 0x4b, 0xd3, 0xc7, 0x05, 0xe4, 0x07, 0x40, 0xd9, 0xb7, 0xc2, 0x12, 0xcb,
    0x9a, 0x90, 0xad, 0xe3, 0x24, 0xe8, 0x5e, 0xa6, 0xf8, 0xd0, 0x6e, 0xbc, 0xd1, 0x69, 0x7f, 0x6b,
    0xe4, 0x2b, 0x4e, 0x1a, 0x65, 0xbb, 0x73, 0x88, 0x6b, 0x7c, 0xaf, 0x7e, 0xd0, 0x47, 0x26, 0xeb,
    0xa5, 0xbe, 0xd6, 0xe8, 0xee, 0x9c, 0xa5, 0x66, 0xa5, 0xc9, 0xd3, 0x25, 0x13, 0xc4, 0x0e, 0x6c,
    0xab, 0x50, 0xb6, 0x50, 0xc9, 0xce, 0x8f, 0x0a, 0x0b, 0xc6, 0x28, 0x69, 0xe9, 0x83, 0x69, 0xde,
    0x42, 0x56, 0x79, 0x7f, 0xde, 0x86, 0x24, 0xca, 0xfc, 0xaa, 0xc0, 0xf3, 0xf3, 0x7f, 0x92, 0x8e,
    0x8a, 0x12, 0x52, 0xfe, 0x50, 0xb1, 0x5e, 0x8c, 0x01, 0xce, 0xfc, 0x7e, 0xf2, 0x4f, 0x5f, 0x03,
    0xfe, 0xa7, 0xcd, 0xa1, 0xfc, 0x94, 0x52, 0x00, 0x8b, 0x9b, 0x7f, 0x09, 0xab, 0xa8, 0xa4, 0xf5,
    0xb4, 0xa5, 0xaa, 0xfc, 0x72, 0xeb, 0x17, 0x40, 0xa9, 0xee, 0xbe, 0x8f, 0xc2, 0xd1, 0x80, 0xc2,
    0x0d, 0x44, 0xa9, 0x59, 0x44, 0x59, 0x81, 0x3b, 0x5d, 0x4a, 0xde, 0xfb, 0xae, 0x24, 0xfc, 0xa3,
    0xd9, 0xbc, 0x57, 0x55, 0xc2, 0x26, 0xbc, 0x19, 0xa7, 0x9a, 0xc5, 0x59, 0xa3, 0xee, 0x5a, 0xef,
    0x41, 0x80, 0x7d, 0xf8, 0x5e, 0xc1, 0x1d, 0x32, 0x38, 0x41, 0x5b, 0xb6, 0x92, 0xb8, 0xb7, 0x03,
    0x0d, 0x3e, 0x59, 0x0f, 0x1c, 0xb3, 0xe1, 0x2a, 0x95, 0x1a, 0x3b, 0x50, 0x4f, 0xc4, 0x1d, 0xcf,
    0x73, 0x7c, 0x14, 0xca, 0xe3, 0x0b, 0xa7, 0xc7, 0x1a, 0x41, 0x4a, 0xee, 0xbe, 0x1f, 0x43, 0xdd,
    0xf9, 0x02, 0x03, 0x01, 0x00, 0x01,
};

static const uint8_t g_pubData3072[] = {
    0x30, 0x82, 0x01, 0xa2, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
    0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x8f, 0x00, 0x30, 0x82, 0x01, 0x8a, 0x02, 0x82, 0x01, 0x81,
    0x00, 0xda, 0xa5, 0x05, 0x33, 0x0c, 0x08, 0x77, 0x97, 0xf3, 0x9f, 0x11, 0xab, 0x2c, 0xb3, 0xc0,
    0xd7, 0xd2, 0x4e, 0x84, 0x62, 0xd8, 0x40, 0x27, 0x4f, 0xb3, 0x3e, 0xa4, 0x61, 0x75, 0xa9, 0x20,
    0x1f, 0xc4, 0xe2, 0x79, 0xe9, 0xf5, 0xba, 0xcc, 0x49, 0x30, 0x03, 0xf3, 0xd4, 0x1b, 0x81, 0xa2,
    0x2e, 0xa3, 0x3a, 0x1e, 0xb9, 0x5e, 0xdc, 0xcd, 0x1b, 0xad, 0x64, 0xfb, 0xb6, 0x78, 0x2f, 0xf6,
    0x14, 0x8d, 0x5f, 0x23, 0xca, 0xbd, 0x81, 0xa5, 0x66, 0xfa, 0x26, 0xc8, 0xe1, 0xa4, 0x16, 0x23,
    0x78, 0x49, 0x00, 0xc1, 0xe5, 0xa8, 0xa0, 0x2f, 0xf7, 0xac, 0xcc, 0x82, 0x6f, 0xa1, 0x89, 0xd9,
    0x2f, 0x44, 0x9f, 0x3d, 0x42, 0x81, 0xae, 0x0e, 0xcb, 0x83, 0xaf, 0x4c, 0x7a, 0x82, 0x2c, 0x8e,
    0xc6, 0x88, 0x18, 0x09, 0xaf, 0x15, 0xd0, 0xe9, 0xfa, 0xb5, 0xc2, 0x67, 0xac, 0x49, 0x96, 0x5b,
    0x42, 0x99, 0x20, 0x95, 0xb2, 0xf7, 0x26, 0x31, 0x83, 0x8c, 0x22, 0x09, 0xea, 0x63, 0xe4, 0x12,
    0x8a, 0x42, 0x3a, 0x71, 0xc9, 0xa0, 0xb5, 0xb2, 0x45, 0xe6, 0x0d, 0xda, 0x94, 0xd3, 0x70, 0xcc,
    0x7f, 0x31, 0xd4, 0x3f, 0xe6, 0xed, 0xf5, 0x43, 0x73, 0xf6, 0x06, 0x7f, 0x13, 0x65, 0x43, 0xd4,
    0x35, 0xf2, 0xfc, 0x75, 0x3a, 0xfe, 0x8e, 0x14, 0x5e, 0xa1, 0xed, 0xd1, 0xd2, 0x96, 0x88, 0xbb,
    0xe4, 0x23, 0x52, 0x51, 0x02, 0x81, 0xa6, 0xf9, 0xad, 0x81, 0xf4, 0xf0, 0xc0, 0x40, 0xbf, 0x4b,
    0x97, 0x6f, 0x87, 0x8e, 0xc7, 0xbd, 0xf2, 0x73, 0x2f, 0xe5, 0x3c, 0x62, 0xba, 0x5f, 0xac, 0xb9,
    0x83, 0x0c, 0x61, 0x74, 0xed, 0x0b, 0xbe, 0xff, 0x2a, 0xcf, 0x6d, 0xff, 0xc4, 0x16, 0x3b, 0xb4,
    0x2b, 0x57, 0x62, 0x84, 0xa6, 0x6f, 0xfb, 0x32, 0x72, 0xd7, 0x61, 0xc2, 0x1d, 0x54, 0x3b, 0xa2,
    0xd2, 0x47, 0xe0, 0x96, 0x72, 0xad, 0x28, 0x75, 0xfe, 0x47, 0xdf, 0xf6, 0xcb, 0xaf, 0x56, 0x9d,
    0x2b, 0x1d, 0x62, 0x26, 0xd8, 0xe5, 0xa6, 0x2a, 0xc9, 0x0a, 0x85, 0x71, 0x63, 0x2e, 0x16, 0x17,
    0xf4, 0x2f, 0x17, 0x01, 0x8a, 0x3d, 0x2f, 0xd2, 0xb2, 0x80, 0xa1, 0x04, 0x30, 0x38, 0x0c, 0xeb,
    0x06, 0x2e, 0xc4, 0x4f, 0x80, 0xfb, 0x6b, 0xf7, 0x3c, 0x53, 0x41, 0x5e, 0xdc, 0xc1, 0xfd, 0x1a,
    0xda, 0x0c, 0x58, 0xa5, 0xb0, 0x99, 0xb2, 0xcd, 0x8f, 0x52, 0x81, 0xd1, 0x82, 0xb2, 0x3b, 0x07,
    0xaf, 0xd0, 0xd4, 0xd7, 0x92, 0xd3, 0x51, 0x87, 0x13, 0x4c, 0xf7, 0x87, 0xb9, 0x74, 0x42, 0xde,
    0x8c, 0x65, 0xe2, 0x68, 0xce, 0x62, 0x5d, 0x02, 0xed, 0xa6, 0xff, 0xf2, 0x87, 0x2a, 0x00, 0xae,
    0xbe, 0xe0, 0xda, 0xe5, 0xfe, 0xb4, 0xb8, 0x0a, 0xfb, 0xfe, 0x89, 0x43, 0xde, 0xd2, 0xb6, 0x4e,
    0x81, 0x02, 0x03, 0x01, 0x00, 0x01,
};

static const uint8_t g_pubData4096[] = {
    0x30, 0x82, 0x02, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
    0x01, 0x05, 0x00, 0x03, 0x82, 0x02, 0x0f, 0x00, 0x30, 0x82, 0x02, 0x0a, 0x02, 0x82, 0x02, 0x01,
    0x00, 0xcd, 0x1f, 0x40, 0xcd, 0x37, 0x56, 0x2f, 0x78, 0xbb, 0x27, 0x1e, 0xba, 0x66, 0xba, 0x84,
    0xc6, 0xdb, 0xa0, 0x72, 0xf3, 0x1b, 0x53, 0x8c, 0x46, 0x99, 0x65, 0x0d, 0xf7, 0xb4, 0xae, 0x19,
    0x46, 0x1e, 0x05, 0xb0, 0xbc, 0xe1, 0x84, 0x9b, 0x44, 0xc5, 0x06, 0x18, 0xef, 0x68, 0x4b, 0x80,
    0xf4, 0xfc, 0x00, 0x79, 0x8e, 0x21, 0x5e, 0x8f, 0x26, 0x65, 0x69, 0x09, 0x31, 0x4b, 0xa0, 0x95,
    0x37, 0x53, 0xa2, 0xf5, 0x52, 0x78, 0xb5, 0x3c, 0xec, 0x58, 0x25, 0x1f, 0x23, 0x99, 0x89, 0xc1,
    0x46, 0x29, 0x65, 0xbb, 0xbe, 0x59, 0x4c, 0xe4, 0x6f, 0xfc, 0xeb, 0x53, 0xe5, 0x33, 0x6e, 0x9a,
    0x14, 0x57, 0x2a, 0x39, 0xc5, 0xec, 0x4e, 0xc3, 0x3e, 0xcf, 0x76, 0xa3, 0xe9, 0xf8, 0xe3, 0x8a,
    0x40, 0x1b, 0x3d, 0x07, 0x0e, 0xe4, 0x8e, 0xc7, 0x03, 0xbe, 0xf0, 0x3b, 0xb1, 0x25, 0x4d, 0x20,
    0x07, 0x9d, 0x2a, 0x18, 0x92, 0x4b, 0x62, 0x34, 0x73, 0xbc, 0x60, 0x3c, 0x18, 0xa2, 0xf8, 0x23,
    0x3f, 0x43, 0xa5, 0xd8, 0x0c, 0x3f, 0x36, 0xd3, 0x4a, 0x83, 0xe8, 0x93, 0xce, 0x55, 0x6b, 0x31,
    0xeb, 0x8e, 0x8d, 0xc0, 0x01, 0x96, 0xee, 0x4c, 0x15, 0xf1, 0x21, 0x5b, 0x34, 0xe9, 0x42, 0x1a,
    0x4a, 0x7b, 0x6f, 0x58, 0x0b, 0x44, 0x4b, 0xc6, 0x9e, 0x15, 0x1c, 0xb9, 0x49, 0x97, 0x99, 0xfc,
    0x4b, 0xac, 0x9e, 0xc8, 0xfe, 0x97, 0xf7, 0x56, 0x62, 0x7e, 0x8f, 0x0e, 0xd2, 0x8a, 0xc3, 0x65,
    0x72, 0xe8, 0xcd, 0xb0, 0xbb, 0x21, 0x95, 0xb5, 0x4a, 0x6e, 0x57, 0x13, 0xf9, 0x68, 0x9f, 0xab,
    0x53, 0xe8, 0xab, 0x10, 0x36, 0x6f, 0x0f, 0x53, 0x53, 0x0b, 0xcd, 0x9b, 0x16, 0x7f, 0x33, 0xfa,
    0x45, 0x2d, 0x52, 0x4d, 0x67, 0x5d, 0x4e, 0xcd, 0x67, 0xef, 0x32, 0x09, 0x09, 0xe6, 0x26, 0x37,
    0x63, 0x4e, 0x43, 0x4e, 0x70, 0xc1, 0xc8, 0xc7, 0xf1, 0x98, 0x81, 0xa3, 0x94, 0xa3, 0x3f, 0xe5,
    0x40, 0x00, 0x26, 0xf9, 0xef, 0x37, 0x57, 0xdc, 0xf4, 0x14, 0x52, 0x8e, 0x24, 0xf2, 0x80, 0xf7,
    0x09, 0x94, 0x29, 0x04, 0xc0, 0x93, 0xdc, 0xc4, 0xfb, 0x67, 0xa3, 0x93, 0x48, 0xfe, 0x3e, 0x50,
    0x3e, 0x40, 0xbf, 0xa5, 0xfb, 0x73, 0xf7, 0x72, 0xad, 0x1e, 0x79, 0x95, 0x3d, 0x52, 0x06, 0x6c,
    0xc1, 0xfa, 0x63, 0x92, 0xcd, 0xfc, 0xc8, 0x61, 0x9f, 0x8d, 0xc1, 0xc3, 0xce, 0x5d, 0x88, 0xcd,
    0xf0, 0xce, 0x82, 0xb4, 0x2d, 0x17, 0x01, 0x03, 0x74, 0xb1, 0x4c, 0x7c, 0xeb, 0x53, 0xd6, 0x2a,
    0x4c, 0x99, 0xb1, 0x17, 0x89, 0xb6, 0x50, 0x37, 0x51, 0xb4, 0xea, 0x54, 0x4f, 0x34, 0x5c, 0xc2,
    0xa6, 0xe7, 0x15, 0x6c, 0x35, 0xa4, 0x18, 0x76, 0x44, 0x52, 0xda, 0x66, 0x0c, 0x18, 0x49, 0x2f,
    0x7e, 0x54, 0x59, 0xfa, 0x9c, 0xbb, 0xc3, 0xf4, 0x57, 0x59, 0x53, 0x90, 0xca, 0x73, 0x62, 0xc6,
    0xbd, 0xd4, 0x37, 0x0f, 0x6b, 0xb8, 0x6f, 0xbf, 0x24, 0xd4, 0xef, 0xde, 0x98, 0x9c, 0x05, 0x30,
    0xc5, 0xa6, 0xb9, 0x39, 0xe8, 0x5b, 0xc5, 0x30, 0xb8, 0x18, 0xb0, 0x86, 0x33, 0x1f, 0x36, 0x64,
    0xe7, 0x18, 0xd5, 0x05, 0xf5, 0x7d, 0x23, 0xe7, 0xdd, 0x96, 0x1a, 0x82, 0xf4, 0xfd, 0x90, 0x86,
    0x69, 0xb5, 0x4b, 0x7b, 0xec, 0x4d, 0x1a, 0x78, 0xad, 0x6f, 0x55, 0x69, 0xc7, 0x8d, 0x69, 0x00,
    0x8b, 0x56, 0x8e, 0x4c, 0xef, 0x1d, 0xe3, 0xa8, 0xbd, 0xa8, 0x93, 0xfc, 0xc8, 0xc9, 0x1f, 0x4c,
    0x0c, 0x64, 0xc4, 0x42, 0x15, 0xdc, 0xfd, 0x57, 0x44, 0xe6, 0xf8, 0x83, 0xc5, 0xb5, 0x97, 0x2a,
    0xd1, 0x0d, 0x30, 0xb4, 0xef, 0xac, 0x7f, 0xc8, 0xcf, 0x90, 0x83, 0x89, 0xb3, 0x2c, 0xc7, 0xb0,
    0x5b, 0x02, 0x03, 0x01, 0x00, 0x01,
};

static struct HksParam g_importRsaKeyParams[] = {
    { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_RSA },
    { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY },
    { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_RSA_KEY_SIZE_512 },
    { .tag = HKS_TAG_PADDING, .uint32Param = HKS_PADDING_PSS },
    { .tag = HKS_TAG_DIGEST, .uint32Param = HKS_DIGEST_SHA256 },
    { .tag = HKS_TAG_IMPORT_KEY_TYPE, .uint32Param = HKS_KEY_TYPE_PRIVATE_KEY },
};

static struct HksParam g_importRsaKeyAnotherParams[] = {
    { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_RSA },
    { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY },
    { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_RSA_KEY_SIZE_512 },
    { .tag = HKS_TAG_IMPORT_KEY_TYPE, .uint32Param = HKS_KEY_TYPE_PRIVATE_KEY },
};

static struct HksParam g_initOp1Params[] = {
    { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_RSA },
    { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_SIGN },
    { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_RSA_KEY_SIZE_512 },
    { .tag = HKS_TAG_PADDING, .uint32Param = HKS_PADDING_PSS },
    { .tag = HKS_TAG_DIGEST, .uint32Param = HKS_DIGEST_SHA256 },
};

static struct HksParam g_initOp2Params[] = {
    { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_RSA },
    { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_VERIFY },
    { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_RSA_KEY_SIZE_512 },
    { .tag = HKS_TAG_PADDING, .uint32Param = HKS_PADDING_PSS },
    { .tag = HKS_TAG_DIGEST, .uint32Param = HKS_DIGEST_SHA256 },
};

static struct HksParam g_updateParams[] = {
    { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_RSA },
};

static struct HksParam g_finishParams[] = {
    { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_RSA },
};

static int32_t CopyKey(const struct HksBlob *key, struct HksBlob *outKey)
{
    uint8_t *outData = (uint8_t *)HksMalloc(key->size);
    if (outData == nullptr) {
        return HKS_ERROR_MALLOC_FAIL;
    }

    (void)memcpy_s(outData, key->size, key->data, key->size);
    outKey->data = outData;
    outKey->size = key->size;

    return HKS_SUCCESS;
}

static int32_t ConstructPubKey(uint32_t keySize, struct HksBlob *outKey)
{
    struct HksBlob pubDataBlob = { 0, nullptr };
    switch (keySize) {
        case HKS_RSA_KEY_SIZE_512:
            pubDataBlob.size = sizeof(g_pubData512);
            pubDataBlob.data = (uint8_t *)g_pubData512;
            break;
        case HKS_RSA_KEY_SIZE_768:
            pubDataBlob.size = sizeof(g_pubData768);
            pubDataBlob.data = (uint8_t *)g_pubData768;
            break;
        case HKS_RSA_KEY_SIZE_1024:
            pubDataBlob.size = sizeof(g_pubData1024);
            pubDataBlob.data = (uint8_t *)g_pubData1024;
            break;
        case HKS_RSA_KEY_SIZE_2048:
            pubDataBlob.size = sizeof(g_pubData2048);
            pubDataBlob.data = (uint8_t *)g_pubData2048;
            break;
        case HKS_RSA_KEY_SIZE_3072:
            pubDataBlob.size = sizeof(g_pubData3072);
            pubDataBlob.data = (uint8_t *)g_pubData3072;
            break;
        case HKS_RSA_KEY_SIZE_4096:
            pubDataBlob.size = sizeof(g_pubData4096);
            pubDataBlob.data = (uint8_t *)g_pubData4096;
            break;
        default:
            return HKS_ERROR_INVALID_KEY_SIZE;
    }
    return CopyKey(&pubDataBlob, outKey);
}

static int32_t ConstructKey(const struct HksBlob *nDataBlob, const struct HksBlob *dDataBlob,
    uint32_t keySize, struct HksBlob *outKey, bool isPriKey)
{
    struct HksKeyMaterialRsa material;
    material.keyAlg = HKS_ALG_RSA;
    material.keySize = keySize;
    material.nSize = nDataBlob->size;
    material.eSize = isPriKey ? 0 : sizeof(g_eData);
    material.dSize = dDataBlob->size;

    uint32_t sizeTest = sizeof(material) + material.nSize + material.eSize + material.dSize;
    uint8_t *data = (uint8_t *)HksMalloc(sizeTest);
    if (data == nullptr) {
        return HKS_ERROR_MALLOC_FAIL;
    }

    // copy struct material
    if (memcpy_s(data, sizeTest, &material, sizeof(material)) != EOK) {
        HKS_FREE(data);
        return HKS_ERROR_BAD_STATE;
    }

    uint32_t offset = sizeof(material);
    // copy nData
    if (memcpy_s(data + offset, sizeTest - offset, nDataBlob->data, nDataBlob->size) != EOK) {
        HKS_FREE(data);
        return HKS_ERROR_BAD_STATE;
    }

    offset += material.nSize;
    // copy eData
    if (!isPriKey) {
        if (memcpy_s(data + offset, sizeTest - offset, &g_eData, sizeof(g_eData)) != EOK) {
            HKS_FREE(data);
            return HKS_ERROR_BAD_STATE;
        }
        offset += material.eSize;
    }

    // copy dData
    if (memcpy_s(data + offset, sizeTest - offset, dDataBlob->data, dDataBlob->size) != EOK) {
        HKS_FREE(data);
        return HKS_ERROR_BAD_STATE;
    }

    outKey->data = data;
    outKey->size = sizeTest;
    return HKS_SUCCESS;
}

static int32_t ConstructImportedKey(uint32_t keySize, uint32_t importType, struct HksBlob *outKey)
{
    if (importType == HKS_KEY_TYPE_PUBLIC_KEY) {
        return ConstructPubKey(keySize, outKey);
    }

    struct HksBlob nDataBlob = { 0, nullptr };
    struct HksBlob dDataBlob = { 0, nullptr };

    bool isPriKey = (importType == HKS_KEY_TYPE_PRIVATE_KEY) ? true : false;
    switch (keySize) {
        case HKS_RSA_KEY_SIZE_512:
            nDataBlob.size = sizeof(g_nData512);
            nDataBlob.data = (uint8_t *)g_nData512;
            dDataBlob.size = sizeof(g_dData512);
            dDataBlob.data = (uint8_t *)g_dData512;
            break;
        case HKS_RSA_KEY_SIZE_768:
            nDataBlob.size = sizeof(g_nData768);
            nDataBlob.data = (uint8_t *)g_nData768;
            dDataBlob.size = sizeof(g_dData768);
            dDataBlob.data = (uint8_t *)g_dData768;
            break;
        case HKS_RSA_KEY_SIZE_1024:
            nDataBlob.size = sizeof(g_nData1024);
            nDataBlob.data = (uint8_t *)g_nData1024;
            dDataBlob.size = sizeof(g_dData1024);
            dDataBlob.data = (uint8_t *)g_dData1024;
            break;
        case HKS_RSA_KEY_SIZE_2048:
            nDataBlob.size = sizeof(g_nData2048);
            nDataBlob.data = (uint8_t *)g_nData2048;
            dDataBlob.size = sizeof(g_dData2048);
            dDataBlob.data = (uint8_t *)g_dData2048;
            break;
        case HKS_RSA_KEY_SIZE_3072:
            nDataBlob.size = sizeof(g_nData3072);
            nDataBlob.data = (uint8_t *)g_nData3072;
            dDataBlob.size = sizeof(g_dData3072);
            dDataBlob.data = (uint8_t *)g_dData3072;
            break;
        case HKS_RSA_KEY_SIZE_4096:
            nDataBlob.size = sizeof(g_nData4096);
            nDataBlob.data = (uint8_t *)g_nData4096;
            dDataBlob.size = sizeof(g_dData4096);
            dDataBlob.data = (uint8_t *)g_dData4096;
            break;
        default:
            return HKS_ERROR_INVALID_KEY_SIZE;
    }

    return ConstructKey(&nDataBlob, &dDataBlob, keySize, outKey, isPriKey);
}

static void ModifyImportParams(uint32_t purpose, uint32_t keySize, uint32_t padding,
    uint32_t digest, uint32_t importType)
{
    g_importRsaKeyParams[TAG_PURPOSE_ID].uint32Param = purpose;
    g_importRsaKeyParams[TAG_KEY_SIZE_ID].uint32Param = keySize;
    g_importRsaKeyParams[TAG_PADDING_ID].uint32Param = padding;
    g_importRsaKeyParams[TAG_DIGEST_ID].uint32Param = digest;
    g_importRsaKeyParams[TAG_IMPOT_TYPE_ID].uint32Param = importType;
}

static void ModifyImportAnotherParams(uint32_t purpose, uint32_t keySize, uint32_t importType)
{
    g_importRsaKeyAnotherParams[TAG_PURPOSE_ID].uint32Param = purpose;
    g_importRsaKeyAnotherParams[TAG_KEY_SIZE_ID].uint32Param = keySize;
    g_importRsaKeyAnotherParams[TAG_IMPORT_NEW_INDEX].uint32Param = importType;
}

static void ModifyinitOp1Params(uint32_t purpose, uint32_t keySize, uint32_t padding, uint32_t digest)
{
    g_initOp1Params[TAG_PURPOSE_ID].uint32Param = purpose;
    g_initOp1Params[TAG_KEY_SIZE_ID].uint32Param = keySize;
    g_initOp1Params[TAG_PADDING_ID].uint32Param = padding;
    g_initOp1Params[TAG_DIGEST_ID].uint32Param = digest;
}

static void ModifyinitOp2Params(uint32_t purpose, uint32_t keySize, uint32_t padding, uint32_t digest)
{
    g_initOp2Params[TAG_PURPOSE_ID].uint32Param = purpose;
    g_initOp2Params[TAG_KEY_SIZE_ID].uint32Param = keySize;
    g_initOp2Params[TAG_PADDING_ID].uint32Param = padding;
    g_initOp2Params[TAG_DIGEST_ID].uint32Param = digest;
}

static int32_t ImportKey(const struct HksBlob *keyAlias, const struct HksParam *params, uint32_t paramCount)
{
    struct HksParamSet *paramSet = nullptr;
    int32_t ret = InitParamSet(&paramSet, params, paramCount);
    if (ret != HKS_SUCCESS) {
        return ret;
    }

    struct HksBlob key = { 0, nullptr };

    // The caller guarantees that the access will not cross the border
    ret = ConstructImportedKey(params[TAG_KEY_SIZE_ID].uint32Param, params[TAG_IMPOT_TYPE_ID].uint32Param, &key);
    if (ret != HKS_SUCCESS) {
        HksFreeParamSet(&paramSet);
        return ret;
    }
    ret = HksImportKeyForDe(keyAlias, paramSet, &key);
    HKS_FREE(key.data);
    HksFreeParamSet(&paramSet);
    return ret;
}

static int32_t ImportKeyNew(const struct HksBlob *keyAlias, const struct HksParam *params, uint32_t paramCount)
{
    struct HksParamSet *paramSet = nullptr;
    int32_t ret = InitParamSet(&paramSet, params, paramCount);
    if (ret != HKS_SUCCESS) {
        return ret;
    }

    struct HksBlob key = { 0, nullptr };

    // The caller guarantees that the access will not cross the border
    ret = ConstructImportedKey(params[TAG_KEY_SIZE_ID].uint32Param, params[TAG_KEY_SIZE_NEW_INDEX].uint32Param, &key);
    if (ret != HKS_SUCCESS) {
        HksFreeParamSet(&paramSet);
        return ret;
    }
    ret = HksImportKeyForDe(keyAlias, paramSet, &key);
    HKS_FREE(key.data);
    HksFreeParamSet(&paramSet);
    return ret;
}

static int32_t ConstructPurpose(uint32_t inputPurpose, uint32_t &outPurposePri, uint32_t &outPurposePair,
    uint32_t &outPurposePub)
{
    outPurposePri = inputPurpose;
    outPurposePair = inputPurpose;
    outPurposePub = inputPurpose;
    if (inputPurpose == (HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY)) {
        outPurposePri = HKS_KEY_PURPOSE_SIGN;
        outPurposePair = HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY;
        outPurposePub = HKS_KEY_PURPOSE_VERIFY;
    } else if (inputPurpose == (HKS_KEY_PURPOSE_ENCRYPT | HKS_KEY_PURPOSE_DECRYPT)) {
        outPurposePri = HKS_KEY_PURPOSE_DECRYPT;
        outPurposePair = HKS_KEY_PURPOSE_ENCRYPT | HKS_KEY_PURPOSE_DECRYPT;
        outPurposePub = HKS_KEY_PURPOSE_ENCRYPT;
    } else {
        return HKS_ERROR_NOT_SUPPORTED;
    }
    return HKS_SUCCESS;
}

static int32_t ConstructOpPurpose(uint32_t inputPurpose, uint32_t &outOp1Purpose, uint32_t &outOp2Purpose)
{
    outOp1Purpose = HKS_KEY_PURPOSE_SIGN;
    outOp2Purpose = HKS_KEY_PURPOSE_VERIFY;
    if (inputPurpose == (HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY)) {
        outOp1Purpose = HKS_KEY_PURPOSE_SIGN;
        outOp2Purpose = HKS_KEY_PURPOSE_VERIFY;
    } else if (inputPurpose == (HKS_KEY_PURPOSE_ENCRYPT | HKS_KEY_PURPOSE_DECRYPT)) {
        outOp1Purpose = HKS_KEY_PURPOSE_ENCRYPT;
        outOp2Purpose = HKS_KEY_PURPOSE_DECRYPT;
    } else {
        return HKS_ERROR_NOT_SUPPORTED;
    }
    return HKS_SUCCESS;
}

static int32_t ConstructParamSets(const struct HksParam *initParams, uint32_t initParamCount,
    struct HksParamSet **initParamSetTest, struct HksParamSet **updateParamSet, struct HksParamSet **finishParamSet)
{
    int32_t ret = InitParamSet(initParamSetTest, initParams, initParamCount);
    if (ret != HKS_SUCCESS) {
        return ret;
    }

    ret = InitParamSet(updateParamSet, g_updateParams, sizeof(g_updateParams) / sizeof(struct HksParam));
    if (ret != HKS_SUCCESS) {
        HksFreeParamSet(initParamSetTest);
        return ret;
    }

    ret = InitParamSet(finishParamSet, g_finishParams, sizeof(g_finishParams) / sizeof(struct HksParam));
    if (ret != HKS_SUCCESS) {
        HksFreeParamSet(initParamSetTest);
        HksFreeParamSet(updateParamSet);
    }
    return ret;
}

static int32_t DoOpDetail(const struct HksBlob *keyAlias, const struct HksParam *initParams, uint32_t initParamCount,
    const struct HksBlob *inData, struct HksBlob *outData)
{
    struct HksParamSet *initParamSetTest = nullptr;
    struct HksParamSet *updateParamSet = nullptr;
    struct HksParamSet *finishParamSet = nullptr;
    int32_t ret = ConstructParamSets(initParams, initParamCount, &initParamSetTest, &updateParamSet, &finishParamSet);
    if (ret != HKS_SUCCESS) {
        return ret;
    }

    do {
        uint64_t handleValue = 0;
        struct HksBlob handle = { sizeof(uint64_t), (uint8_t *)&handleValue };
        ret = HksInitForDe(keyAlias, initParamSetTest, &handle, nullptr);
        if (ret != HKS_SUCCESS) {
            break;
        }

        uint8_t tempBuf[LENGTH_TO_BE_OPERATED] = {0};
        struct HksBlob tmpBlob = { LENGTH_TO_BE_OPERATED, tempBuf };
        struct HksBlob tmpBlob2 = { 0, nullptr };

        ret = HksUpdateForDe(&handle, updateParamSet, inData, &tmpBlob);
        if (ret != HKS_SUCCESS) {
            break;
        }
        
        // The caller guarantees that the access will not cross the border
        if (initParams[TAG_PURPOSE_ID].uint32Param == HKS_KEY_PURPOSE_VERIFY) {
            ret = HksFinishForDe(&handle, finishParamSet, outData, &tmpBlob2);
        } else {
            ret = HksFinishForDe(&handle, finishParamSet, &tmpBlob2, outData);
        }
    } while (0);

    HksFreeParamSet(&initParamSetTest);
    HksFreeParamSet(&updateParamSet);
    HksFreeParamSet(&finishParamSet);
    return ret;
}

static int32_t DoDecrpyt(const struct HksBlob *keyAlias, const struct HksBlob *cipherData, const struct HksBlob *pData)
{
    uint8_t *plainBuf = (uint8_t *)HksMalloc(LENGTH_MAX);
    if (plainBuf == nullptr) {
        return HKS_ERROR_MALLOC_FAIL;
    }
    struct HksBlob plainData = { LENGTH_MAX, plainBuf };

    int32_t ret = DoOpDetail(keyAlias, g_initOp2Params, sizeof(g_initOp2Params) / sizeof(struct HksParam),
        cipherData, &plainData);
    if (ret != HKS_SUCCESS) {
        HKS_FREE(plainBuf);
        return ret;
    }

    if (plainData.size == pData->size && memcmp(plainData.data, pData->data, pData->size) == 0) {
        ret = HKS_SUCCESS;
    } else {
        ret = HKS_FAILURE;
    }

    HKS_FREE(plainBuf);
    return ret;
}

static int32_t DoOperation(const struct HksBlob *priKeyAlias, const struct HksBlob *pairKeyAlias)
{
    struct HksBlob keyAliasOp1 = { 0, nullptr };
    struct HksBlob keyAliasOp2 = { 0, nullptr };
    if (g_initOp1Params[TAG_PURPOSE_ID].uint32Param == HKS_KEY_PURPOSE_SIGN) {
        keyAliasOp1 = *priKeyAlias;
        keyAliasOp2 = *pairKeyAlias;
    } else {
        keyAliasOp1 = *pairKeyAlias;
        keyAliasOp2 = *priKeyAlias;
    }

    uint8_t *inDataBuf = (uint8_t *)HksMalloc(LENGTH_TO_BE_OPERATED);
    if (inDataBuf == nullptr) {
        return HKS_ERROR_MALLOC_FAIL;
    }

    uint8_t *outDataBuf = (uint8_t *)HksMalloc(LENGTH_MAX);
    if (outDataBuf == nullptr) {
        HKS_FREE(inDataBuf);
        return HKS_ERROR_MALLOC_FAIL;
    }

    struct HksBlob inData = { LENGTH_TO_BE_OPERATED, inDataBuf };
    struct HksBlob outData = { LENGTH_MAX, outDataBuf };
    (void)HksGenerateRandom(nullptr, &inData);

    int32_t ret;
    do {
        /* operation 1: sign or encrypt */
        ret = DoOpDetail(&keyAliasOp1, g_initOp1Params, sizeof(g_initOp1Params) / sizeof(struct HksParam),
            &inData, &outData);
        if (ret != HKS_SUCCESS) {
            break;
        }

        /* operation 2: verify or decrypt */
        if (g_initOp2Params[TAG_PURPOSE_ID].uint32Param == HKS_KEY_PURPOSE_VERIFY) {
            ret = DoOpDetail(&keyAliasOp2, g_initOp2Params, sizeof(g_initOp2Params) / sizeof(struct HksParam),
                &inData, &outData);
        } else {
            ret = DoDecrpyt(&keyAliasOp2, &outData, &inData);
        }
    } while (0);

    HKS_FREE(inDataBuf);
    HKS_FREE(outDataBuf);
    return ret;
}

static void RsaImportPlainKeyAnotherTest(uint32_t purpose, uint32_t keySize, uint32_t padding, uint32_t digest)
{
    uint32_t purposePri;
    uint32_t purposePair;
    uint32_t purposePub;
    int32_t ret = ConstructPurpose(purpose, purposePri, purposePair, purposePub);
    EXPECT_EQ(ret, HKS_SUCCESS) << "construct purpose failed";

    // import rsa private-key
    uint8_t priAlias[] = "import_rsa_private_key";
    struct HksBlob priKeyAlias = { sizeof(priAlias), priAlias };
    
    ModifyImportAnotherParams(purposePri, keySize, HKS_KEY_TYPE_PRIVATE_KEY);
    ret = ImportKeyNew(&priKeyAlias, g_importRsaKeyAnotherParams,
        sizeof(g_importRsaKeyAnotherParams) / sizeof(struct HksParam));
    EXPECT_EQ(ret, HKS_SUCCESS) << "import pri key failed";

    // import rsa key-pair
    uint8_t pairAlias[] = "import_rsa_key_pair";
    struct HksBlob pairKeyAlias = { sizeof(pairAlias), pairAlias };

    ModifyImportAnotherParams(purposePair, keySize, HKS_KEY_TYPE_KEY_PAIR);
    ret = ImportKeyNew(&pairKeyAlias, g_importRsaKeyAnotherParams,
        sizeof(g_importRsaKeyAnotherParams) / sizeof(struct HksParam));
    
    EXPECT_EQ(ret, HKS_SUCCESS) << "import key pair failed";

    // import rsa pubKey
    uint8_t pubAlias[] = "import_rsa_public_key";
    struct HksBlob pubKeyAlias = { sizeof(pubAlias), pubAlias };

    ModifyImportAnotherParams(purposePub, keySize, HKS_KEY_TYPE_PUBLIC_KEY);
    ret = ImportKeyNew(&pubKeyAlias, g_importRsaKeyAnotherParams,
        sizeof(g_importRsaKeyAnotherParams) / sizeof(struct HksParam));
    EXPECT_EQ(ret, HKS_SUCCESS) << "import key public failed";

    uint32_t purposeOp1;
    uint32_t purposeTestOp2;
    ret = ConstructOpPurpose(purpose, purposeOp1, purposeTestOp2);
    EXPECT_EQ(ret, HKS_SUCCESS) << "construct operation purpose failed";

    ModifyinitOp1Params(purposeOp1, keySize, padding, digest);
    ModifyinitOp2Params(purposeTestOp2, keySize, padding, digest);

    ret = DoOperation(&priKeyAlias, &pairKeyAlias);
    EXPECT_EQ(ret, HKS_SUCCESS) << "operation failed";
    ret = DoOperation(&priKeyAlias, &pubKeyAlias);
    EXPECT_EQ(ret, HKS_SUCCESS) << "operation 2 failed";

    // export public key
    uint8_t pubKeyTest[HKS_RSA_KEY_SIZE_1024] = {0};
    struct HksBlob publicKey = { HKS_RSA_KEY_SIZE_1024, pubKeyTest };
    ret = HksExportPublicKeyForDe(&pubKeyAlias, nullptr, &publicKey);
    EXPECT_EQ(ret, HKS_SUCCESS) << "ExportPublicKey failed.";

    // delete keys
    (void)HksDeleteKeyForDe(&priKeyAlias, nullptr);
    (void)HksDeleteKeyForDe(&pairKeyAlias, nullptr);
    (void)HksDeleteKeyForDe(&pubKeyAlias, nullptr);
}

static void RsaImportPlainKeyTest(uint32_t purpose, uint32_t keySize, uint32_t padding, uint32_t digest)
{
    uint32_t purposePri;
    uint32_t purposePair;
    uint32_t purposePub;
    int32_t ret = ConstructPurpose(purpose, purposePri, purposePair, purposePub);
    EXPECT_EQ(ret, HKS_SUCCESS) << "construct purpose failed";

    // import rsa private-key
    uint8_t priAlias[] = "import_rsa_private_key";
    struct HksBlob priKeyAlias = { sizeof(priAlias), priAlias };
    
    ModifyImportParams(purposePri, keySize, padding, digest, HKS_KEY_TYPE_PRIVATE_KEY);
    ret = ImportKey(&priKeyAlias, g_importRsaKeyParams, sizeof(g_importRsaKeyParams) / sizeof(struct HksParam));
    EXPECT_EQ(ret, HKS_SUCCESS) << "import pri key failed";

    // import rsa key-pair
    uint8_t pairAlias[] = "import_rsa_key_pair";
    struct HksBlob pairKeyAlias = { sizeof(pairAlias), pairAlias };
    ModifyImportParams(purposePair, keySize, padding, digest, HKS_KEY_TYPE_KEY_PAIR);
    ret = ImportKey(&pairKeyAlias, g_importRsaKeyParams, sizeof(g_importRsaKeyParams) / sizeof(struct HksParam));
    EXPECT_EQ(ret, HKS_SUCCESS) << "import key pair failed";

    // import rsa pubKey
    uint8_t pubAlias[] = "import_rsa_public_key";
    struct HksBlob pubKeyAlias = { sizeof(pubAlias), pubAlias };
    ModifyImportParams(purposePub, keySize, padding, digest, HKS_KEY_TYPE_PUBLIC_KEY);
    ret = ImportKey(&pubKeyAlias, g_importRsaKeyParams, sizeof(g_importRsaKeyParams) / sizeof(struct HksParam));
    EXPECT_EQ(ret, HKS_SUCCESS) << "import key public failed";

    uint32_t purposeOp1;
    uint32_t purposeOp2;
    ret = ConstructOpPurpose(purpose, purposeOp1, purposeOp2);
    EXPECT_EQ(ret, HKS_SUCCESS) << "construct operation purpose failed";

    ModifyinitOp1Params(purposeOp1, keySize, padding, digest);
    ModifyinitOp2Params(purposeOp2, keySize, padding, digest);

    ret = DoOperation(&priKeyAlias, &pairKeyAlias);
    EXPECT_EQ(ret, HKS_SUCCESS) << "operation failed";
    ret = DoOperation(&priKeyAlias, &pubKeyAlias);
    EXPECT_EQ(ret, HKS_SUCCESS) << "operation 2 failed";

    // export public key
    uint8_t pubKey[HKS_RSA_KEY_SIZE_1024] = {0};
    struct HksBlob publicKey = { HKS_RSA_KEY_SIZE_1024, pubKey };
    ret = HksExportPublicKeyForDe(&pubKeyAlias, nullptr, &publicKey);
    EXPECT_EQ(ret, HKS_SUCCESS) << "ExportPublicKey failed.";

    // delete keys
    (void)HksDeleteKeyForDe(&priKeyAlias, nullptr);
    (void)HksDeleteKeyForDe(&pairKeyAlias, nullptr);
    (void)HksDeleteKeyForDe(&pubKeyAlias, nullptr);
}

static void ImportRsaPlainKeyTest(uint32_t purpose, uint32_t keySize, uint32_t padding, uint32_t digest)
{
    return RsaImportPlainKeyTest(purpose, keySize, padding, digest);
}

static void ImportRsaPlainKeyAnotherTest(uint32_t purpose, uint32_t keySize, uint32_t padding, uint32_t digest)
{
    return RsaImportPlainKeyAnotherTest(purpose, keySize, padding, digest);
}
/**
 * @tc.name: HksImportRsaTest.HksImportRsaTest001
 * @tc.desc: import rsa 512-sign/verify-pss-sha256
 * @tc.type: FUNC normal
 */
HWTEST_F(HksImportRsaTest, HksImportRsaTest001, TestSize.Level0)
{
    ImportRsaPlainKeyTest(HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY, HKS_RSA_KEY_SIZE_512,
        HKS_PADDING_PSS, HKS_DIGEST_SHA256);
}

/**
 * @tc.name: HksImportRsaTest.HksImportRsaTest002
 * @tc.desc: import rsa 768-sign/verify-pss-sha256
 * @tc.type: FUNC normal
 */
HWTEST_F(HksImportRsaTest, HksImportRsaTest002, TestSize.Level0)
{
    ImportRsaPlainKeyTest(HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY, HKS_RSA_KEY_SIZE_768,
        HKS_PADDING_PSS, HKS_DIGEST_SHA384);
}

/**
 * @tc.name: HksImportRsaTest.HksImportRsaTest003
 * @tc.desc: import rsa 1024-sign/verify-pss-sha256
 * @tc.type: FUNC normal
 */
HWTEST_F(HksImportRsaTest, HksImportRsaTest003, TestSize.Level0)
{
    ImportRsaPlainKeyTest(HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY, HKS_RSA_KEY_SIZE_1024,
        HKS_PADDING_PSS, HKS_DIGEST_SHA512);
}

/**
 * @tc.name: HksImportRsaTest.HksImportRsaTest004
 * @tc.desc: import rsa 2048-encrypt/decrypt-oaep-sha256
 * @tc.type: FUNC normal
 */
HWTEST_F(HksImportRsaTest, HksImportRsaTest004, TestSize.Level0)
{
    ImportRsaPlainKeyTest(HKS_KEY_PURPOSE_ENCRYPT | HKS_KEY_PURPOSE_DECRYPT, HKS_RSA_KEY_SIZE_2048,
        HKS_PADDING_OAEP, HKS_DIGEST_SHA1);
}

/**
 * @tc.name: HksImportRsaTest.HksImportRsaTest005
 * @tc.desc: import rsa 3072-encrypt/decrypt-oape-sha256
 * @tc.type: FUNC normal
 */
HWTEST_F(HksImportRsaTest, HksImportRsaTest005, TestSize.Level0)
{
    ImportRsaPlainKeyTest(HKS_KEY_PURPOSE_ENCRYPT | HKS_KEY_PURPOSE_DECRYPT, HKS_RSA_KEY_SIZE_3072,
        HKS_PADDING_OAEP, HKS_DIGEST_SHA256);
}

/**
 * @tc.name: HksImportRsaTest.HksImportRsaTest006
 * @tc.desc: import rsa 4096-encrypt/decrypt-oape-sha256
 * @tc.type: FUNC normal
 */
HWTEST_F(HksImportRsaTest, HksImportRsaTest006, TestSize.Level0)
{
    ImportRsaPlainKeyTest(HKS_KEY_PURPOSE_ENCRYPT | HKS_KEY_PURPOSE_DECRYPT, HKS_RSA_KEY_SIZE_4096,
        HKS_PADDING_OAEP, HKS_DIGEST_SHA256);
}
#endif

#ifdef HKS_UNTRUSTED_RUNNING_ENV
/**
 * @tc.name: HksImportRsaTest.HksImportRsaTest007
 * @tc.desc: import rsa 512-sign/verify-pss-sha256
 * @tc.type: FUNC normal
 * @tc.require:issueI611S5
 */
HWTEST_F(HksImportRsaTest, HksImportRsaTest007, TestSize.Level0)
{
    HKS_LOG_E("Enter HksImportRsaTest007");
    ImportRsaPlainKeyAnotherTest(HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY, HKS_RSA_KEY_SIZE_512,
        HKS_PADDING_PSS, HKS_DIGEST_SHA256);
}

/**
 * @tc.name: HksImportRsaTest.HksImportRsaTest008
 * @tc.desc: import rsa 768-sign/verify-pss-sha256
 * @tc.type: FUNC normal
 * @tc.require:issueI611S5
 */
HWTEST_F(HksImportRsaTest, HksImportRsaTest008, TestSize.Level0)
{
    HKS_LOG_E("Enter HksImportRsaTest008");
    ImportRsaPlainKeyAnotherTest(HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY, HKS_RSA_KEY_SIZE_768,
        HKS_PADDING_PSS, HKS_DIGEST_SHA384);
}

/**
 * @tc.name: HksImportRsaTest.HksImportRsaTest009
 * @tc.desc: import rsa 1024-sign/verify-pss-sha256
 * @tc.type: FUNC normal
 * @tc.require:issueI611S5
 */
HWTEST_F(HksImportRsaTest, HksImportRsaTest009, TestSize.Level0)
{
    HKS_LOG_E("Enter HksImportRsaTest009");
    ImportRsaPlainKeyAnotherTest(HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY, HKS_RSA_KEY_SIZE_1024,
        HKS_PADDING_PSS, HKS_DIGEST_SHA384);
}
#endif
} // namespace Unittest::ImportRsaTest
